---
layout: "default"
title: "String.UnicodeScalarView"
description: "Swift documentation for 'String.UnicodeScalarView': A collection of `Unicode scalar values."
keywords: "String.UnicodeScalarView,struct,swift,documentation,append,extend,generate,getMirror,insert,removeAll,removeAtIndex,removeRange,replaceRange,reserveCapacity,splice,debugDescription,description,endIndex,startIndex,Generator,Element,Index,SubSequence"
root: "/v1.2"
---

<div class="intro-declaration"><code class="language-swift">struct String.UnicodeScalarView</code></div>

<div class="discussion comment">
    <p>A collection of <a href="http://www.unicode.org/glossary/#unicode_scalar_value">Unicode scalar values</a> that
encode a <code>String</code> .</p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">CollectionType, DebugPrintable, ExtensibleCollectionType, Printable, RangeReplaceableCollectionType, Reflectable, SequenceType, Sliceable, _CollectionType, _ExtensibleCollectionType, _SequenceType, _Sequence_Type, _Sliceable</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>

<tr>
<th id="aliases">Associated Types</th>
<td>
<span id="aliasesmark"></span>
<div class="declaration">
<code class="language-swift">Generator = String.UnicodeScalarView.Generator</code>
<div class="comment">
    <p><em>Type alias inferred.</em></p>
</div>
</div>
<div class="declaration">
<code class="language-swift">Element = UnicodeScalar</code>
<div class="comment">
    <p><em>Type alias inferred.</em></p>
</div>
</div>
<div class="declaration">
<code class="language-swift">Index = String.UnicodeScalarView.Index</code>
<div class="comment">
    <p><em>Type alias inferred.</em></p>
</div>
</div>
<div class="declaration">
<code class="language-swift">SubSequence = String.UnicodeScalarView</code>
<div class="comment">
    <p><em>Type alias inferred.</em></p>
</div>
</div>
</td>
</tr>

<tr>
<th>Nested Types</th>
<td><code class="nested">String.UnicodeScalarView.Index, String.UnicodeScalarView.Generator</code></td>
</tr>

<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>


<h3>Initializers</h3>
<div class="declaration" id="init">
<a class="toggle-link" data-toggle="collapse" href="#comment-init">init()</a><div class="comment collapse" id="comment-init"><div class="p">
    <p>Construct an empty instance.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init()</code>

    </div></div>
</div>


<h3>Instance Variables</h3>
<div class="declaration" id="var-debugdescription_-string">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-debugdescription_-string">var debugDescription: String</a><div class="comment collapse" id="comment-var-debugdescription_-string"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">var debugDescription: String { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-description_-string">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-description_-string">var description: String</a><div class="comment collapse" id="comment-var-description_-string"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">var description: String { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-endindex_-string-unicodescalarview-index">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-endindex_-string-unicodescalarview-index">var endIndex: String.UnicodeScalarView.Index</a><div class="comment collapse" id="comment-var-endindex_-string-unicodescalarview-index"><div class="p">
    <p>The &quot;past the end&quot; position.</p>

<p><code>endIndex</code> is not a valid argument to <code>subscript</code>, and is always
reachable from <code>startIndex</code> by zero or more applications of
<code>successor()</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var endIndex: String.UnicodeScalarView.Index { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-startindex_-string-unicodescalarview-index">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-startindex_-string-unicodescalarview-index">var startIndex: String.UnicodeScalarView.Index</a><div class="comment collapse" id="comment-var-startindex_-string-unicodescalarview-index"><div class="p">
    <p>The position of the first <code>UnicodeScalar</code> if the <code>String</code> is
non-empty; identical to <code>endIndex</code> otherwise.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var startIndex: String.UnicodeScalarView.Index { get }</code>

    </div></div>
</div>

<h3>Subscripts</h3>
<div class="declaration" id="subscript-subscript_-string-unicodescalarview-index">
<a class="toggle-link" data-toggle="collapse" href="#comment-subscript-subscript_-string-unicodescalarview-index">subscript(_: String.UnicodeScalarView.Index)</a>
<div class="comment collapse" id="comment-subscript-subscript_-string-unicodescalarview-index"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">subscript(position: String.UnicodeScalarView.Index) -&gt; UnicodeScalar { get }</code>
    
    
</div></div>
</div>
<div class="declaration" id="subscript-subscript_-range-string-unicodescalarview-index">
<a class="toggle-link" data-toggle="collapse" href="#comment-subscript-subscript_-range-string-unicodescalarview-index">subscript(_: Range&lt;String.UnicodeScalarView.Index&gt;)</a>
<div class="comment collapse" id="comment-subscript-subscript_-range-string-unicodescalarview-index"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">subscript(r: Range&lt;String.UnicodeScalarView.Index&gt;) -&gt; String.UnicodeScalarView { get }</code>
    
    
</div></div>
</div>


<h3>Instance Methods</h3>
<div class="declaration" id="func-append_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-append_">mutating func append(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-append_"><div class="p">
    <p>Append <code>x</code> to <code>self</code>.</p>

<p>Complexity: amortized O(1).</p>

    <h4>Declaration</h4>    
    <code class="language-swift">mutating func append(x: UnicodeScalar)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-extend_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-extend_">mutating func extend(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-extend_"><div class="p">
    <p>Append the elements of <code>newElements</code> to <code>self</code>.</p>

<p>Complexity: O(<em>length of result</em>) </p>

    <h4>Declaration</h4>    
    <code class="language-swift">mutating func extend&lt;S : SequenceType where UnicodeScalar == UnicodeScalar&gt;(newElements: S)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-generate">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-generate">func generate()</a>
        
<div class="comment collapse" id="comment-func-generate"><div class="p">
    <p>Return a <em>generator</em> over the <code>UnicodeScalar</code>s that comprise
this <em>sequence</em>.</p>

<p>Complexity: O(1)</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func generate() -&gt; String.UnicodeScalarView.Generator</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-getmirror">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-getmirror">func getMirror()</a>
        
<div class="comment collapse" id="comment-func-getmirror"><div class="p">
    <p>Returns a mirror that reflects <code>self</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func getMirror() -&gt; MirrorType</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-insert_atindex_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-insert_atindex_">mutating func insert(<wbr>_:<wbr>atIndex:)</a>
        
<div class="comment collapse" id="comment-func-insert_atindex_"><div class="p">
    <p>Insert <code>newElement</code> at index <code>i</code>.</p>

<p>Invalidates all indices with respect to <code>self</code>.</p>

<p>Complexity: O(<code>count(self)</code>).</p>

    <h4>Declaration</h4>    
    <code class="language-swift">mutating func insert(newElement: UnicodeScalar, atIndex i: String.UnicodeScalarView.Index)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-removeall_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-removeall_">mutating func removeAll(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-removeall_"><div class="p">
    <p>Remove all elements.</p>

<p>Invalidates all indices with respect to <code>self</code>.</p>

<p><strong><code>keepCapacity</code></strong>, if <code>true</code>, prevents the release of
  allocated storage, which can be a useful optimization
  when <code>self</code> is going to be grown again.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">mutating func removeAll(keepCapacity: Bool = default)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-removeatindex_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-removeatindex_">mutating func removeAtIndex(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-removeatindex_"><div class="p">
    <p>Remove the and return element at index <code>i</code></p>

<p>Invalidates all indices with respect to <code>self</code>.</p>

<p>Complexity: O(<code>count(self)</code>).</p>

    <h4>Declaration</h4>    
    <code class="language-swift">mutating func removeAtIndex(i: String.UnicodeScalarView.Index) -&gt; UnicodeScalar</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-removerange_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-removerange_">mutating func removeRange(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-removerange_"><div class="p">
    <p>Remove the indicated <code>subRange</code> of elements</p>

<p>Invalidates all indices with respect to <code>self</code>.</p>

<p>Complexity: O(<code>count(self)</code>).</p>

    <h4>Declaration</h4>    
    <code class="language-swift">mutating func removeRange(subRange: Range&lt;String.UnicodeScalarView.Index&gt;)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-replacerange_with_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-replacerange_with_">mutating func replaceRange(<wbr>_:<wbr>with:)</a>
        
<div class="comment collapse" id="comment-func-replacerange_with_"><div class="p">
    <p>Replace the given <code>subRange</code> of elements with <code>newElements</code>.</p>

<p>Invalidates all indices with respect to <code>self</code>.</p>

<p>Complexity: O(<code>count(subRange)</code>) if <code>subRange.endIndex
== self.endIndex</code> and <code>isEmpty(newElements)</code>, O(N) otherwise.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">mutating func replaceRange&lt;C : CollectionType where UnicodeScalar == UnicodeScalar&gt;(subRange: Range&lt;String.UnicodeScalarView.Index&gt;, with newElements: C)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-reservecapacity_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-reservecapacity_">mutating func reserveCapacity(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-reservecapacity_"><div class="p">
    <p>Reserve enough space to store <code>n</code> ASCII characters.</p>

<p>Complexity: O(<code>n</code>)</p>

    <h4>Declaration</h4>    
    <code class="language-swift">mutating func reserveCapacity(n: Int)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-splice_atindex_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-splice_atindex_">mutating func splice(<wbr>_:<wbr>atIndex:)</a>
        
<div class="comment collapse" id="comment-func-splice_atindex_"><div class="p">
    <p>Insert <code>newElements</code> at index <code>i</code></p>

<p>Invalidates all indices with respect to <code>self</code>.</p>

<p>Complexity: O(<code>count(self) + count(newElements)</code>).</p>

    <h4>Declaration</h4>    
    <code class="language-swift">mutating func splice&lt;S : CollectionType where UnicodeScalar == UnicodeScalar&gt;(newElements: S, atIndex i: String.UnicodeScalarView.Index)</code>
    
    
</div></div>
</div>


